<!--  -->
<template>
  <div>
    <van-panel title="基本信息">
      <ui-card>
        <template v-slot:title>
          {{ baseinfo.projectName }}
        </template>
        <div class="pre-line">
          {{ baseinfo.projectDescribe }}
        </div>
      </ui-card>
      <van-cell-group>
        <van-cell :value="baseinfo.address" icon="location-o" />
        <van-cell
          title="合同编号"
          :label="baseinfo.contractNum"
          icon="notes-o"
        />
        <van-cell title="面积" :label="baseinfo.subsidyBasis" icon="expand-o" />
        <van-cell
          title="补贴依据"
          :label="baseinfo.contractNum"
          icon="records"
        />
        <van-cell title="联系人" :label="baseinfo.contractMan" icon="contact" />
        <van-cell
          title="联系方式"
          :label="baseinfo.contractFunc"
          icon="phone-o"
        />
      </van-cell-group>
    </van-panel>
    <van-panel title="联系企业">
      <ui-card v-for="eps in baseinfo.contractEnterprise" :key="eps.id">
        <template v-slot:title>
          {{ eps.name }}
        </template>
        <van-cell-group>
          <van-cell :value="eps.address" icon="location-o" />
          <van-cell title="签约日期" :label="eps.contractDate" icon="edit" />
          <van-cell title="终止日期" :label="eps.deadLine" icon="calender-o" />
          <van-cell title="备注" :label="eps.remarks" icon="more-o" />
        </van-cell-group>
      </ui-card>
      <div slot="footer">
        <van-cell title="附件" />
      </div>
    </van-panel>

    <van-steps direction="vertical" :active="100000">
      <van-step v-for="attach in baseinfo.attachList" :key="attach.id">
        <template v-if="attach.file">
          <a :href="attach.url" :download="attach.attachName">
            <van-cell :title="attach.attachName" icon="down" />
          </a>
        </template>
        <template v-else>
          <div @click="openimg(attach.url)">
            <ui-img :src="attach.url" style="width:100%;height:160px">{{
              attach.attachName
            }}</ui-img>
          </div>
        </template>
      </van-step>
    </van-steps>
  </div>
</template>

<script>
import { getBaseinfo } from "@api";
import { ImagePreview } from "vant";
export default {
  name: "info",
  data() {
    return {
      baseinfo: {}
    };
  },
  mounted() {
    getBaseinfo(this.$route.params.id).then(res => {
      this.baseinfo = res.data;
    });
  },

  methods: {
    openimg(url) {
      ImagePreview({
        images: [url],
        closeable: true
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.van-icon {
  top: 5px;
}
</style>
